import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import Axios from "./util/maxios.js";
import Api from "./api";
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUI);
Vue.prototype.$api = Api;
Vue.prototype.$axios = Axios;
Vue.config.productionTip = false;

this.$axios.post(this.$api.user.userLogin, {
  userNm: "admin",
  userPwd: "123123"
})
.then(res => {
  if (res.data == "登录成功") {
    this.$message.success("登录成功");
    localStorage.setItem("isLogin", true);
    this.$router.push("home");
  } else {
    this.$message.error({
      message: res.data,
      center: true,
      duration: 2000
    });
    return false;
  }
})
.catch(err => {
  console.log(err);
  this.$message.error({
    message: "请求出错，请联系管理员",
    center: true,
    duration: 2000
  });
  return false;
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
